package cn.tedu.spring.di;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



/**
 * @author lhd
 * @date 2024/4/16
 * @apiNote
 */
@Service
public class UserService {
    /*
        Autowired 注解：
            1.自动装配注解 注入对象类型和接口类型的数据
            2.添加位置
                属性上
                set方法上
                构造方法上

     */
//    @Autowired
    // 放在属性上
    private UserDao userDao;


    //@Autowired
    //放在构造器上
    public UserService(UserDao userDao) {
        this.userDao = userDao;
    }
    @Autowired
    // 放在set方法上
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public UserService() {
    }


    public void run()
    {
        userDao.run();
    }


    @Override
    public String toString() {
        return "UserService{" +
                "userDao=" + userDao +
                '}';
    }
}
